package com.demo.demo1;import java.io.IOException;import java.net.InetSocketAddress;import java.nio.ByteBuffer;import java.nio.channels.Channel;import java.nio.channels.ServerSocketChannel;import java.nio.channels.SocketChannel;public class Server {    public static void main(String[] args) throws IOException {//        打开通道        ServerSocketChannel ssc = ServerSocketChannel.open();//        建立服务端        ssc.socket().bind(new InetSocketAddress(8899));//        获取socket        SocketChannel socket = ssc.accept();        ByteBuffer bb = ByteBuffer.allocate(1024);        socket.read(bb);        System.out.println(new String(bb.array(),0,bb.position()));        bb.clear();        bb.put("收到请求。。。。".getBytes());        //将缓冲区切换成输出模式        bb.flip();    }}